import { create } from 'zustand';

const useUiStore = create((set, get) => ({
  // 全局加载动画 { status: boolean, message: string, percent: number }
  loading: {
    status: false,
    message: '',
    percent: 0
  },
  // 剪切的文件对象
  cutFile: null,
  // 显示全局加载动画
  showLoading: (message) => {
    set({ loading: { status: true, message, percent: 0 } });
  },
  // 隐藏全局加载动画
  hideLoading: () => {
    set({ loading: { status: false, message: '', percent: 0 } });
  },
  // 设置全局加载动画的百分比
  setProgress: (percent) => {
    set({ loading: { ...get().loading, percent } });
  },
  // 设置剪切的文件对象
  setCutFile: (file) => {
    set({ cutFile: file });
  }
}));

export default useUiStore;
